package cn.iocoder.yudao.module.system.dal.mysql.seatreserve;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.dal.dataobject.seatreserve.SeatReserveDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.system.controller.admin.seatreserve.vo.*;

/**
 * 座位预定信息 Mapper
 *
 * @author Warren365
 */
@Mapper
public interface SeatReserveMapper extends BaseMapperX<SeatReserveDO> {

    default PageResult<SeatReserveDO> selectPage(SeatReservePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SeatReserveDO>()
                .inIfPresent(SeatReserveDO::getReserveStatus, reqVO.getNoReserveStatus())//非预定座位
                .inIfPresent(SeatReserveDO::getReserveTime, reqVO.getReserveTimeAllday())//全天预定
                .eqIfPresent(SeatReserveDO::getReserveStatus, reqVO.getReserveStatus())
                .betweenIfPresent(SeatReserveDO::getSignTime, reqVO.getSignTime())
                .betweenIfPresent(SeatReserveDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(SeatReserveDO::getOfficeId, reqVO.getOfficeId())
                .eqIfPresent(SeatReserveDO::getReserveTime, reqVO.getReserveTime())
                .eqIfPresent(SeatReserveDO::getCancelUserid, reqVO.getCancelUserid())
                .betweenIfPresent(SeatReserveDO::getCancelTime, reqVO.getCancelTime())
                .eqIfPresent(SeatReserveDO::getIsSign, reqVO.getIsSign())
                .likeIfPresent(SeatReserveDO::getReserverUsername, reqVO.getReserverUsername())
                .likeIfPresent(SeatReserveDO::getCancelUsername, reqVO.getCancelUsername())
                .eqIfPresent(SeatReserveDO::getSeatId, reqVO.getSeatId())
                .eqIfPresent(SeatReserveDO::getReserverUserid, reqVO.getReserverUserid())
                .betweenIfPresent(SeatReserveDO::getReserveDate, reqVO.getReserveDate())
                .orderByDesc(SeatReserveDO::getId));
    }

    default List<SeatReserveDO> selectByMap(Map<String,Object> reqVO) {
        return selectList(new LambdaQueryWrapperX<SeatReserveDO>()
                .eqIfPresent(SeatReserveDO::getOfficeId, reqVO.get("officeId"))
                .orderByDesc(SeatReserveDO::getId));
    }

}